/**
 * 
 */
package com.neal.web.controller;

import java.util.Date;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.neal.domain.securities.Function;
import com.neal.domain.securities.User;

/**
 * @author Neal
 * @version 1.0
 * @description
 */
@Controller
@RequestMapping("/welcome")
public class WelcomeController {

	@RequestMapping(value = "hello", method = RequestMethod.GET)
	public String welcome(@RequestParam String[] name,HttpSession session, Model model) {
		model.addAttribute("today", new Date());
		model.addAttribute("name", name[0] + " haha");
		User user = (User) session.getAttribute("user");
		if(user != null){
			System.out.println(user.getUserId());
		}else{
			System.out.println("null user");
		}
		return "welcome";
	}
	
	@RequestMapping(value = "user", method = RequestMethod.GET)
	public String findUser(@ModelAttribute("user") User user,Model model) {
		Function function = new Function();
		function.setCode("110");
		return "welcome";
	}
	
	@RequestMapping("testBind")
	public String do4(@RequestParam Date date,Model model){
		System.out.println(date.toString());
		return "welcome";
	}
}
